<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户登录——单点登录系统</title>
    <link href="<%=request.getContextPath() %>/res/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>
	    <form style="width: 330px;margin: 0 auto; padding: 15px;"  action="<%=request.getContextPath() %>/login" method="post">
	    <h2 >用户中心</h2>
	    <div id="errormsg" class="form-group">
	    </div>
		  <div class="form-group input-group">
		    <div class="input-group-addon">账号</div>
		    <input type="text" name="userName" class="form-control input-lg" id="userName" placeholder="账号" />
		  </div>
		  <div class="form-group input-group">
		    <div class="input-group-addon">密码</div>
		    <input type="password" name="password" class="form-control input-lg" id="password" placeholder="密码" />
		  </div>
		  <div class="form-group">
		    <div class="input-group">
		        <input type="text" name="captcha" class="form-control input-lg" placeholder="验证码" />
		         <div class="input-group-addon" style="width: 130px;"><img id="captcha-img" style="width: 110px;" class="img-responsive img-rounded" onclick="getCaptcha()" alt="验证码" /></div>
		    </div>
		  </div>
		  <input type="hidden" name="service" value="${service}" />
		  <div class="form-group">
		  	<button type="submit" class="btn btn-lg btn-primary btn-block">登   录</button>
		  </div>
		  <div class="form-group">
		  	<label>没有账号？请点击 <a href="<%=request.getContextPath() %>/toRegister">注册</a></label>
		  </div>
		</form>
	    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
	    <script src="<%=request.getContextPath() %>/res/js/bootstrap.min.js"></script>
    
    <script type="text/javascript">
		function getCaptcha(){
			$("#captcha-img").attr("src","<%=request.getContextPath() %>"+"/captcha?date="+new Date().getTime());
		}
		function showErrorMsg(){
			var errorMsg="${login_error_msg }";
			if(errorMsg!=null && errorMsg!=""){
				$("#errormsg").html("<div  class=\"alert alert-danger\">"+errorMsg+"</div>");
			}
		}
		$(function() {
			showErrorMsg();
			getCaptcha();
			
		});
	</script>
  </body>
</html>